SUBDIRS = third network framework lsheeps lserverhook
THIRDDIRS = lua lua_3rd
SODIRS = Sheeps
OTDIRS = supersheeps
INSTALLDIR = ./bin

all:
	@list='$(SUBDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make OUTFILE=$(OUTFILE)); \
	done;
	@list='$(THIRDDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make OUTFILE=$(OUTFILE)); \
	done;
	@list='$(SODIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make OUTFILE=$(OUTFILE)); \
	done;
	@list='$(OTDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make OUTFILE=$(OUTFILE)); \
	done;

release:
	@list='$(SUBDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make release OUTFILE=$(OUTFILE)); \
	done;
	@list='$(THIRDDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make OUTFILE=$(OUTFILE)); \
	done;
	@list='$(SODIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make release OUTFILE=$(OUTFILE)); \
	done;
	@list='$(OTDIRS)'; for subdir in $$list; do \
	echo "MAKING ALL IN $$subdir"; \
	(cd $$subdir && make release OUTFILE=$(OUTFILE)); \
	done;

clean:
	@list='$(SUBDIRS)'; for subdir in $$list; do \
	echo "MAKINT CLEAN IN $$subdir"; \
	(cd $$subdir && make clean OUTFILE=$(OUTFILE)); \
	done;
	@list='$(THIRDDIRS)'; for subdir in $$list; do \
	echo "MAKINT CLEAN IN $$subdir"; \
	(cd $$subdir && make clean OUTFILE=$(OUTFILE)); \
	done;
	@list='$(SODIRS)'; for subdir in $$list; do \
	echo "MAKINT CLEAN IN $$subdir"; \
	(cd $$subdir && make clean OUTFILE=$(OUTFILE)); \
	done;
	@list='$(OTDIRS)'; for subdir in $$list; do \
	echo "MAKINT CLEAN IN $$subdir"; \
	(cd $$subdir && make clean OUTFILE=$(OUTFILE)); \
	done;

install:
	rm -rf $(INSTALLDIR)/*;
	mkdir $(INSTALLDIR) -p;
	cp supersheeps/supersheeps $(INSTALLDIR);
	cp x64/sheeps/Debug/sheeps.ini $(INSTALLDIR);
	@list='$(SODIRS)'; for subdir in $$list; do \
    echo "cp $$subdir/*.so $(INSTALLDIR)/"; \
    (cp $$subdir/*.so $(INSTALLDIR)/); \
    done;
	cp -rf x64/sheeps/Debug/project $(INSTALLDIR);
	cp -rf x64/sheeps/Debug/server $(INSTALLDIR);
	cp -rf x64/sheeps/Debug/liblua $(INSTALLDIR);
	cp -rf x64/sheeps/Debug/case $(INSTALLDIR);
	
